<template>
  <div>
    <el-table :data="XHCKList" border :header-cell-style="{ background: '#eef1f6' }">
      <el-table-column type="index" label="序号" width="50">
      </el-table-column>
      <!-- <el-table-column prop="name" label="日期" sortable></el-table-column> -->
         <el-table-column prop="pricing_method_name" label="定价方式"></el-table-column>
      <el-table-column prop="currency_name" label="币种"></el-table-column>
         <el-table-column
           label="敞口类型"
           prop="exp_type"
           :formatter="formatterET">
         </el-table-column>
         <el-table-column
           label="合同号"
           prop="deal_no">
         </el-table-column>
         <el-table-column
           label="敞口号"
           prop="exposure_no">
         </el-table-column>
         <el-table-column
           label="方向"
           prop="direction"
           :formatter="formatterDirection">
         </el-table-column>
         <el-table-column prop="department_name" label="部门名称"></el-table-column>
          <el-table-column
           label="客户名称"
           prop="customer_name">
         </el-table-column>
         <el-table-column
           label="品名"
           prop="name">
         </el-table-column>
         <el-table-column
           label="单据数量"
           prop="invoice_vol">
         </el-table-column>
         <el-table-column
           label="敞口数量"
           prop="exp_vol">
         </el-table-column>
         <el-table-column
           label="定价开始时间" width="130" sortable
           prop="start_date">
         </el-table-column>
         <el-table-column
           label="定价结束时间" width="130" sortable
           prop="end_date">
         </el-table-column>
         <el-table-column
           label="价格"
           prop="price">
         </el-table-column>
    </el-table>
  </div>
</template>
<script>
import { conExposure } from '../../../../../api/url_lcc';
export default {
  //期初开账-现货敞口
  name: "exposureSpot",
  data() {
    return {
      XHCKList:[],
       CKForm: {
          page: 1, //当前页
          pageSize: 20,
          totalPage: 1,
          begin_flag:"1",
          "commodity_name":"",
          "exp_type":"",
          "direction":"",
          "deal_no":"",
          "direction":"",
          "base_price_name":"",
          "startDate":"",
          "endDate":"",
          "department_name":"",
          "exposure_no":"",
          "salesman":"",
          "depot":"",
          "brand":"",
          "origin":"",
          "depot":"",
          "standard":"",
        },
    };
  },
  methods: {
     // 敞口类型逐笔，净敞口
    formatterET(row, column) {
         if (row.exp_type == "0") {
             return '逐笔';
         } else if (row.exp_type == "1") {
             return '净敞口';
         } 
     },
    //  方向采购,销售
    formatterDirection(row, column) {
         if (row.direction == "0") {
             return '采购';
         } else if (row.direction == "1") {
             return '销售';
         } 
     },
     // 现货敞口查询
   // 每页数
    handleSizeChange(val) {
      this.CKForm.pageSize = val;
      this.CKForm.page = 1;
      this.XHCKChange1();
    },
    // 当前页
    handleCurrentChange1(val) {
      this.CKForm.page = val;
      this.XHCKChange1();
    },
    XHCKChange(){
      this.CKForm.page = 1;
      this.XHCKChange1()
    },
     XHCKChange1(){
        conExposure(this.CKForm).then(res => {
            if (res.errcode == "1") {
                this.XHCKList = []
                var data = res.result.results
                 this.CKForm.totalPage = res.result.count;
                 for (var i = 0; i <= data.length; i++) {
                  this.XHCKList[i] = {
                      'settlement_status': data[i]['settlement_status'],
                      'confirm_status': data[i]['confirm_status'],
                      'department_name': data[i]['department_name'],
                      'red_dashed': data[i]['red_dashed'],
                      'salesman': data[i]['salesman'],
                      "depot": data[i]['depot'],
                      "exp_type": data[i]['exp_type'],
                      "deal_no": data[i]['deal_no'],
                      "exposure_no": data[i]['exposure_no'],
                      "direction": data[i]['direction'],
                      "customer_name": data[i]['customer_name'],
                      "customer": data[i]['customer'],
                      "invoice_vol": data[i]['invoice_vol'],
                      "exp_vol": data[i]['exp_vol'],
                      "start_date": data[i]['start_date'],
                      "end_date": data[i]['end_date'],
                      "department_name": data[i]['department_name'],
                      "department": data[i]['department'],
                      "base_valuation": data[i]['base_valuation'],
                      "exchange_rate": data[i]['exchange_rate'],
                      "unit_price": data[i]['unit_price'],
                      "bwd": data[i]['bwd'],
                      "base_price": data[i]['base_price'],
                      "piece_num": data[i]['piece_num'],
                      "piece_vol": data[i]['piece_vol'],
                      "category": data[i]['category'],
                      "base_price_name": data[i]['base_price_name'],
                      "attribute": data[i].commodity.commodity_spot[0]['attribute'],
                      "brand": data[i].commodity.commodity_spot[0]['brand'],
                      "id": data[i].commodity.commodity_spot[0]['id'],
                      "origin": data[i].commodity.commodity_spot[0]['origin'],
                      "standard": data[i].commodity.commodity_spot[0]['standard'],
                      "remark": data[i]['remark'],
                      "currency_price": data[i]['currency_price'],
                      "commodity": data[i].commodity['id'],//品名ID
                      "name": data[i].commodity['name'],//品名
                      "base_valuation": data[i]['base_valuation'],//估值基准ID
                      "base_price": data[i]['base_price'],//定价基准ID
                      "price": data[i]['price'],
                      "begin_flag": data[i]['begin_flag'],
                      "pricing_method": data[i]['pricing_method'],
                      "customer": data[i]['customer'],
                      "currency": data[i]['currency'],
                      "virtual": data[i]['virtual'],
                      "currency_name": data[i]['currency_name'],
                      "pricing_method_name": data[i]['pricing_method_name'],
                  }
                }
             }else{
                this.$message.error(res.msg);
            }
        });
     },
  },
  mounted(){
    this.XHCKChange()
  }
};
</script>
